#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=85,N=1e7;
int n;
struct node{int c,t,w;}a[Maxn];
int m;
int cnt;
struct Node{int t,w;}b[Maxn*34];
int f[N];
namespace sub1{
	inline void solve(){
		for(int i=1;i<=cnt;i++){
			for(int j=m;j>=b[i].t;j--)
				f[j]=max(f[j],f[j-b[i].t]+b[i].w);
		}
		int ans=0,p=0;
		for(int i=1;i<=m;i++){
			if(ans<f[i])ans=f[i],p=i;
		}
		printf("%lld\n",ans);
	}
}
signed main(){
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	n=read();int sum=0;
	for(int i=1;i<=n;i++)a[i].c=read();
	for(int i=1;i<=n;i++)a[i].t=read(),sum+=a[i].t*a[i].c;
	for(int i=1;i<=n;i++)a[i].w=read();
	m=read();
	m=min(m,sum);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=30;j++)
			if(a[i].c>=(1<<j)){
				b[++cnt]={(1<<j)*a[i].t,(1<<j)*a[i].w};
				a[i].c-=(1<<j);
			}else{
				if(a[i].c)b[++cnt]={a[i].c*a[i].t,a[i].c*a[i].w};
				break;
			}
	}
	if(m*cnt<=1.2e8)sub1::solve(),exit(0);
	return 0;
}

